package com.example.bookstore.security

import javax.servlet.http.HttpServletRequest

/**
 * Created by IntelliJ IDEA.
 * User: lvshe
 * Date: 2019/8/13
 * Time: 19:07
 */
interface TokenService {
    companion object {
        const val SECRET = "BOOKSTORE"
        const val EXPIRED_TIME_MS = 3 * 60 * 60 * 1000L
    }

    fun parseUsernameFromToken(request: HttpServletRequest): String?
    fun createTokenForUsername(username: String): String

    fun checkTokenFromSession(key: String, token: String): Boolean
    fun saveTokenToSession(key: String, token: String): Boolean
    fun removeTokenFromSession(key: String, token: String): Boolean
    fun getUserTokensFromSession(key: String, identity: String):  Set<String>
}